package Demo5;

import java.util.List;

/*
       A
      / \
     B   C
    / \ / \
   D  E F  G
       \
        H
*/
public class Test5 {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        BinaryTree.TreeNode tree = binaryTree.createTree();

        int height = binaryTree.getHeight(tree);
        System.out.println("此二叉树高度为: "+ height);

        List<Character> list = binaryTree.preOrderTraversal(tree);//迭代前序遍历
        System.out.println("前序遍历: "+ list);

        List<Character> inOrderTraversal = binaryTree.inOrderTraversal(tree);//迭代中序遍历
        System.out.println("中序遍历: "+inOrderTraversal);

        List<Character> postOrderTraversal = binaryTree.postOrderTraversal(tree);
        System.out.println("后序遍历: "+postOrderTraversal);//使用两个栈迭代后序遍历

        List<Character> postOrderTraversalOneStack = binaryTree.postOrderTraversalOneStack(tree);
        System.out.println("使用一个栈的后序遍历: "+postOrderTraversalOneStack);//使用一个栈迭代后序遍历


        CompleteBinaryTree completeBinaryTree = new CompleteBinaryTree();
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8};
        completeBinaryTree.initCompleteBinaryTree(arr);
        System.out.println("完全二叉树前序遍历结果: " + completeBinaryTree.preorderTraversal());
    }
}
/*
       1
    2    3
  4  5  6  7
 8

*/
